<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>drag</title>
    <style>
        .wrap {
            width: 200px;
            height: 300px;
            border: 1px solid red;
            margin-bottom: 20px;
        }
    </style>
</head>
<body>
<div class="wrap" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
<div>
    <p draggable="true" ondragstart="drag(event)" id="text1">把这段文字拖入上面的框体中</p>
</div>
</body>
<script>
    function drag(event) {
        event.dataTransfer.setData("Text", event.target.id);
    }

    function drop(event) {
        event.preventDefault();
        var data = event.dataTransfer.getData("Text");
        event.target.appendChild(document.getElementById(data));
    }

    function allowDrop(event) {
        event.preventDefault();
    }
</script>
</html>